home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / CBGRX103.ZIP / contrib / libgrx / utils / tlibcvt.c < prev    next >
Text File  |  1993-12-06  |  2KB  |  62 lines

  1. #include <stdio.h>
  2. #include <stdarg.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <ctype.h>
  6.  
  7. static void usage(char *message,...)
  8. {
  9.     va_list ap;
  10.  
  11.     if(message != NULL) {
  12.         va_start(ap,message);
  13.         vfprintf(stderr,message,ap);
  14.         va_end(ap);
  15.         fprintf(stderr,"\n\n");
  16.     }
  17.     fprintf(stderr,
  18.         "Usage: TLIBCVT <option> [<infile> [<outfile>]]\n\n"
  19.         "    OPTION: TLIB object file option (+, -, +-, *, *+, etc..)\n"
  20.         "        see manual for details\n"
  21.         "    INFILE: input file containing the names of the object\n"
  22.         "        files. If omitted, stdin is used.\n"
  23.         "    OUTFILE: name of the output TLIB response file.\n"
  24.         "       If omitted, stdin is used.\n\n"
  25.         "Converts a list of object files to TLIB\n"
  26.         "(Turbo C Librarian) response file format\n\n"
  27.     );
  28.     exit(-1);
  29. }
  30.  
  31. void main(int argc,char **argv)
  32. {
  33.     char filename[100];
  34.     char *option,*p;
  35.     int  len,pos = 0;
  36.  
  37.     if(argc < 2) usage(NULL);
  38.     option = argv[1];
  39.     if((argc > 2) && (freopen(argv[2],"r",stdin) == NULL))
  40.         usage("can't open input file: %s",argv[2]);
  41.     if((argc > 3) && (freopen(argv[3],"w",stdout) == NULL))
  42.         usage("can't create output file: %s",argv[3]);
  43.     while(scanf("%s",filename) == 1) {
  44.         len = strlen(filename) + strlen(option) + 1;
  45.         for(p = filename; *p != '\0'; p++) {
  46.         *p = toupper(*p);
  47.         if(*p == '/') *p = '\\';
  48.         }
  49.         if((pos + len) > 75) {
  50.         printf(" &\n %s%s",option,filename);
  51.         pos = len;
  52.         }
  53.         else {
  54.         printf(" %s%s",option,filename);
  55.         pos += len;
  56.         }
  57.     }
  58.     printf("\n");
  59.     exit(0);
  60. }
  61.  
  62.